package com.guo.dms.common.utils;


import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element;
/**
 * 存储各种缓存对象到系统中
 * @author Administrator
 *
 */
public class CacheUtils {
	//获取cacheManager
	private static CacheManager cacheManager=SpringContextHolder.getBean(CacheManager.class);
	/**
	 * 获取缓存中的某个值
	 * @param cacheName
	 * @param key
	 * @return
	 */
	public static Object  getCacheValue(String cacheName, String key){
		Cache cache = cacheManager.getCache(cacheName);
		if(cache==null){
			System.err.println(cacheName+" cache is not found!!");
			return null;
		}
	     Element el = cache.get(key);
	     if(el==null){
	    	 System.err.println(key+" Element is not found!!");
			 return null;
	     }
		return el.getObjectValue();
	}
	
	
}
